package util.libraries;

import java.io.File;


/**
 * Creates a static-accessible library of all images in a given directory. Those
 * images will be placed into an array in the same order as within the director.
 * Allows access to these images based on their index in the array.
 * 
 * @author Julian
 */
public abstract class SubDirectoryLibrary extends AbstractLibrary
{

    public SubDirectoryLibrary (String dir)
    {
        super(dir);
    }


    public SubDirectoryLibrary (File dir)
    {
        super(dir);
    }


    @Override
    public void buildLibrary (File directory)
    {
        initialize();
        buildLibrary(directory.listFiles());
    }


    public void buildLibrary (File[] subDir)
    {
        for (File f : subDir)
        {
            if (f.isDirectory()) buildLibrary(f.listFiles());
            else addToLibrary(f);
        }
    }


    protected abstract void initialize ();

}
